home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / godelqc5.zip / WEAPONS.QC < prev    next >
Text File  |  1996-09-23  |  37KB  |  1,564 lines

  1. //prototypes
  2. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  3. void () player_run;
  4. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  5. void(vector org, vector vel, float damage) SpawnBlood;
  6.  
  7. // called by worldspawn
  8. void() W_Precache =
  9. {
  10.     precache_sound ("weapons/r_exp3.wav");  // new rocket explosion
  11.     precache_sound ("weapons/rocket1i.wav");        // spike gun
  12.     precache_sound ("weapons/sgun1.wav");
  13.     precache_sound ("weapons/guncock.wav"); // player shotgun
  14.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  15.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  16.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  17.     precache_sound ("weapons/spike2.wav");  // super spikes
  18.     precache_sound ("weapons/tink1.wav");   // spikes tink (used in c code)
  19.     precache_sound ("weapons/grenade.wav"); // grenade launcher
  20.     precache_sound ("weapons/bounce.wav");          // grenade bounce
  21.     precache_sound ("weapons/shotgn2.wav"); // super shotgun
  22.     precache_sound ("doors/runetry.wav");
  23.     precache_sound ("items/inv1.wav");
  24.     precache_sound ("misc/basekey.wav");
  25.     precache_sound ("items/protect2.wav");
  26.     precache_sound ("items/protect3.wav");
  27.     precache_sound ("items/damage3.wav");
  28.  
  29.  
  30.  
  31. //Added by Godel
  32.     precache_sound ("items/damage.wav");
  33.     precache_sound ("items/damage2.wav");
  34.     precache_sound ("misc/secret.wav"); // capture the flag
  35.     precache_model ("progs/backpack.mdl");
  36.     precache_model ("progs/g_shot.mdl");
  37.     precache_model ("progs/g_nail.mdl");
  38.     precache_model ("progs/g_nail2.mdl");
  39.     precache_model ("progs/g_rock.mdl");
  40.     precache_model ("progs/g_rock2.mdl");
  41.     precache_model ("progs/g_light.mdl");
  42.     precache_model ("progs/armor.mdl");
  43.     precache_model ("maps/b_shell1.bsp");
  44.     precache_model ("maps/b_nail1.bsp");
  45.     precache_model ("maps/b_rock1.bsp");
  46.     precache_model ("maps/b_batt1.bsp");
  47.     precache_model ("progs/eyes.mdl");    
  48.     precache_model ("progs/quaddama.mdl");
  49.     precache_sound ("enforcer/enfire.wav");    // holo sound
  50.     precache_sound ("wizard/wattack.wav");    // vampiric axe sound
  51.     precache_model ("progs/zombie.mdl");
  52.     precache_model ("progs/h_zombie.mdl");
  53.     precache_model ("progs/zom_gib.mdl");
  54.     precache_sound ("zombie/z_idle.wav");
  55.     precache_sound ("zombie/z_idle1.wav");
  56.     precache_sound ("zombie/z_shot1.wav");
  57.     precache_sound ("zombie/z_gib.wav");
  58.     precache_sound ("zombie/z_pain.wav");
  59.     precache_sound ("zombie/z_pain1.wav");
  60.     precache_sound ("zombie/z_fall.wav");
  61.     precache_sound ("zombie/z_miss.wav");
  62.     precache_sound ("zombie/z_hit.wav");
  63.     precache_sound ("zombie/idle_w2.wav");
  64.  
  65. };
  66.  
  67. float() crandom =
  68. {
  69.     return 2*(random() - 0.5);
  70. };
  71.  
  72. /*
  73. ================
  74. W_FireAxe
  75. ================
  76. */
  77. void() W_FireAxe =
  78. {
  79.     local    vector    source;
  80.     local    vector    org;
  81.     local float vamp;
  82.     local float axdam;
  83.  
  84.     makevectors(self.v_angle);
  85.     source = self.origin + '0 0 16';
  86. //Pushing Hands
  87.     if (self.weaponnum==1) {
  88.         W_PushEnemy();
  89.         return;
  90.     }
  91. //Vampiric Axe pulls toward victim
  92.     traceline (source, source + v_forward*256, FALSE, self);
  93.     if ((trace_fraction!=1.0) && (trace_ent.takedamage==DAMAGE_AIM) &&
  94.     (trace_ent.classname!="monster_zombie"))
  95.         self.velocity=self.velocity+((trace_ent.origin-self.origin)*4);
  96.     traceline (source, source + v_forward*128, FALSE, self);
  97.     if (trace_fraction == 1.0)
  98.         return;
  99.     
  100.     org = trace_endpos - v_forward*4;
  101.  
  102.     if (trace_ent.takedamage)
  103.     {
  104.         trace_ent.axhitme = 1;
  105.         if (self.super_damage_finished > time) axdam=80;
  106.         else axdam=20;
  107.             
  108.         SpawnBlood (org, '0 0 0', 20);
  109. // Vampiric Axe Mod
  110.         if (trace_ent.health<axdam) vamp=(trace_ent.health*0.5);
  111.         else vamp=axdam*0.5;
  112.         if (trace_ent.classname=="monster_zombie"){
  113.             sound (self, CHAN_WEAPON, "player/axhit1.wav", 1, ATTN_NORM);
  114.             T_Damage(self,trace_ent,trace_ent,axdam*0.5);    
  115.         } else if (trace_ent.takedamage==DAMAGE_YES) {
  116.             sound (self, CHAN_WEAPON, "player/axhit1.wav", 1, ATTN_NORM);
  117.         } else if (self.health < 100){
  118.             sound (self, CHAN_AUTO, "wizard/wattack.wav", 1, ATTN_NORM);
  119.             if(self.health+vamp>=100) self.health=100;
  120.             else self.health=self.health+vamp;
  121.         } else if (self.health < 200){
  122.             sound (self, CHAN_AUTO, "wizard/wattack.wav", 1, ATTN_NORM);
  123.             if(self.health+vamp>=200) self.health=200;
  124.             else self.health=self.health+1;
  125.         }
  126.         T_Damage (trace_ent, self, self, 20);
  127.     }
  128.     else
  129.     {    // hit wall
  130.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  131.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  132.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  133.         WriteCoord (MSG_BROADCAST, org_x);
  134.         WriteCoord (MSG_BROADCAST, org_y);
  135.         WriteCoord (MSG_BROADCAST, org_z);
  136.     }
  137. };
  138.  
  139. //============================================================================
  140.  
  141.  
  142. vector() wall_velocity =
  143. {
  144.     local vector    vel;
  145.     
  146.     vel = normalize (self.velocity);
  147.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  148.     vel = vel + 2*trace_plane_normal;
  149.     vel = vel * 200;
  150.     
  151.     return vel;
  152. };
  153.  
  154.  
  155. /*
  156. ================
  157. SpawnMeatSpray
  158. ================
  159. */
  160. void(vector org, vector vel) SpawnMeatSpray =
  161. {
  162.     local   entity missile, mpuff;
  163.     local   vector  org;
  164.  
  165.     missile = spawn ();
  166.     missile.owner = self;
  167.     missile.movetype = MOVETYPE_BOUNCE;
  168.     missile.solid = SOLID_NOT;
  169.  
  170.     makevectors (self.angles);
  171.  
  172.     missile.velocity = vel;
  173.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  174.  
  175.     missile.avelocity = '3000 1000 2000';
  176.     
  177. // set missile duration
  178.     missile.nextthink = time + 1;
  179.     missile.think = SUB_Remove;
  180.  
  181.     setmodel (missile, "progs/zom_gib.mdl");
  182.     setsize (missile, '0 0 0', '0 0 0');            
  183.     setorigin (missile, org);
  184. };
  185.  
  186. /*
  187. ================
  188. SpawnBlood
  189. ================
  190. */
  191. void(vector org, vector vel, float damage) SpawnBlood =
  192. {
  193.     particle (org, vel*0.1, 73, damage*2);
  194. };
  195.  
  196. /*
  197. ================
  198. spawn_touchblood
  199. ================
  200. */
  201. void(float damage) spawn_touchblood =
  202. {
  203.     local vector    vel;
  204.  
  205.     vel = wall_velocity () * 0.2;
  206.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  207. };
  208.  
  209.  
  210. /*
  211. ================
  212. SpawnChunk
  213. ================
  214. */
  215. void(vector org, vector vel) SpawnChunk =
  216. {
  217.     particle (org, vel*0.02, 0, 10);
  218. };
  219.  
  220. /*
  221. ==============================================================================
  222.  
  223. MULTI-DAMAGE
  224.  
  225. Collects multiple small damages into a single damage
  226.  
  227. ==============================================================================
  228. */
  229.  
  230. entity  multi_ent;
  231. float   multi_damage;
  232.  
  233. void() ClearMultiDamage =
  234. {
  235.     multi_ent = world;
  236.     multi_damage = 0;
  237. };
  238.  
  239. void() ApplyMultiDamage =
  240. {
  241.     if (!multi_ent)
  242.         return;
  243.     T_Damage (multi_ent, self, self, multi_damage);
  244. };
  245.  
  246. void(entity hit, float damage) AddMultiDamage =
  247. {
  248.     if (!hit)
  249.         return;
  250.     
  251.     if (hit != multi_ent)
  252.     {
  253.         ApplyMultiDamage ();
  254.         multi_damage = damage;
  255.         multi_ent = hit;
  256.     }
  257.     else
  258.         multi_damage = multi_damage + damage;
  259. };
  260.  
  261. /*
  262.  
  263. ==============================================================================
  264.  
  265. BULLETS
  266.  
  267. ==============================================================================
  268. */
  269.  
  270. /*
  271. ================
  272. TraceAttack
  273. ================
  274. */
  275. void(float damage, vector dir) TraceAttack =
  276. {
  277.     local   vector  vel, org;
  278.     
  279.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  280.     vel = vel + 2*trace_plane_normal;
  281.     vel = vel * 200;
  282.  
  283.     org = trace_endpos - dir*4;
  284.  
  285.     if (trace_ent.takedamage)
  286.     {
  287.         SpawnBlood (org, vel*0.2, damage);
  288.         AddMultiDamage (trace_ent, damage);
  289.     }
  290.     else
  291.     {
  292.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  293.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  294.         WriteCoord (MSG_BROADCAST, org_x);
  295.         WriteCoord (MSG_BROADCAST, org_y);
  296.         WriteCoord (MSG_BROADCAST, org_z);
  297.     }
  298. };
  299.  
  300. /*
  301. ================
  302. FireBullets
  303.  
  304. Used by shotgun, super shotgun, and enemy soldier firing
  305. Go to the trouble of combining multiple pellets into a single damage call.
  306. ================
  307. */
  308. void(float shotcount, vector dir, vector spread) FireBullets =
  309. {
  310.     local   vector direction;
  311.     local   vector  src;
  312.  
  313. //Godel qc mod to reduce shotgun spread for long range shotguns
  314.     if (self.weaponnum==1) spread=spread * 0.1;
  315.  
  316.     makevectors(self.v_angle);
  317.     src = self.origin + v_forward*10;
  318.     src_z = self.absmin_z + self.size_z * 0.7;
  319.  
  320.     ClearMultiDamage ();
  321.     while (shotcount > 0)
  322.     {
  323.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  324.  
  325.         traceline (src, src + direction*2048, FALSE, self);
  326.         if (trace_fraction != 1.0)
  327.             TraceAttack (4, direction);
  328.  
  329.         shotcount = shotcount - 1;
  330.     }
  331.     ApplyMultiDamage ();
  332. };
  333.  
  334. /*
  335. ================
  336. W_FireShotgun
  337. ================
  338. */
  339. void() W_FireShotgun =
  340. {
  341.     local vector dir;
  342.  
  343.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM); 
  344.  
  345.     self.punchangle_x = -2;
  346.     
  347.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  348.     dir = aim (self, 100000);
  349.  
  350.     FireBullets (8, dir, '0.04 0.04 0');
  351. };
  352.  
  353. /*
  354. ================
  355. W_FireSuperShotgun
  356. ================
  357. */
  358. void() W_FireSuperShotgun =
  359. {
  360.     local vector dir;
  361.  
  362.     if (self.currentammo == 1)
  363.     {
  364.         W_FireShotgun ();
  365.         return;
  366.     }
  367.         
  368.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM); 
  369.  
  370.     self.punchangle_x = -4;
  371.     
  372.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  373.     dir = aim (self, 100000);
  374.  
  375.     FireBullets (16, dir, '0.14 0.08 0');
  376. };
  377.  
  378.  
  379. /*
  380. ==============================================================================
  381.  
  382. ROCKETS
  383.  
  384. ==============================================================================
  385. */
  386.  
  387. void()  s_explode1      =       [0,             s_explode2] {};
  388. void()  s_explode2      =       [1,             s_explode3] {};
  389. void()  s_explode3      =       [2,             s_explode4] {};
  390. void()  s_explode4      =       [3,             s_explode5] {};
  391. void()  s_explode5      =       [4,             s_explode6] {};
  392. void()  s_explode6      =       [5,             SUB_Remove] {};
  393.  
  394.  
  395. void() BecomeExplosion =
  396. {
  397.     self.movetype = MOVETYPE_NONE;
  398.     self.velocity = '0 0 0';
  399.     self.touch = SUB_Null;
  400.     setmodel (self, "progs/s_explod.spr");
  401.     self.solid = SOLID_NOT;
  402.     s_explode1 ();
  403. };
  404.  
  405. void() T_MissileTouch =
  406. {
  407.     local float     damg;
  408.  
  409.     if (other == self.owner)
  410.         return;         // don't explode on owner
  411.  
  412.     if (pointcontents(self.origin) == CONTENT_SKY)
  413.     {
  414.         remove(self);
  415.         return;
  416.     }
  417.  
  418.     damg = 100 + random()*20;
  419.     
  420.     if (other.health)
  421.     {
  422.         if (other.classname == "monster_shambler")
  423.             damg = damg * 0.5;      // mostly immune
  424.         T_Damage (other, self, self.owner, damg );
  425.     }
  426.  
  427.     // don't do radius damage to the other, because all the damage
  428.     // was done in the impact
  429.     T_RadiusDamage (self, self.owner, 120, other);
  430.  
  431. //      sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  432.     self.origin = self.origin - 8*normalize(self.velocity);
  433.     
  434.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  435.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  436.     WriteCoord (MSG_BROADCAST, self.origin_x);
  437.     WriteCoord (MSG_BROADCAST, self.origin_y);
  438.     WriteCoord (MSG_BROADCAST, self.origin_z);
  439.  
  440.     BecomeExplosion ();
  441.  
  442. };
  443.  
  444.  
  445. /*
  446. ================
  447. W_FireRocket
  448. ================
  449. */
  450. void() W_FireRocket =
  451. {
  452.     local   entity missile, mpuff;
  453.     
  454.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  455.     
  456.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  457.  
  458.     self.punchangle_x = -2;
  459.  
  460.     missile = spawn ();
  461.     missile.owner = self;
  462.     missile.movetype = MOVETYPE_FLYMISSILE;
  463.     missile.solid = SOLID_BBOX;
  464.     missile.classname="missile";
  465.         
  466. // set missile speed    
  467.  
  468.     makevectors (self.v_angle);
  469.     missile.velocity = aim(self, 1000);
  470.     missile.velocity = missile.velocity * 1000;
  471.     missile.angles = vectoangles(missile.velocity);
  472.     
  473.     missile.touch = T_MissileTouch;
  474.     
  475. // set missile duration
  476.     missile.nextthink = time + 5;
  477.     missile.think = SUB_Remove;
  478.     setmodel (missile, "progs/missile.mdl");
  479.     setsize (missile, '0 0 0', '0 0 0');            
  480.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  481. };
  482.  
  483. /*
  484. ===============================================================================
  485.  
  486. LIGHTNING
  487.  
  488. ===============================================================================
  489. */
  490.  
  491. /*
  492. =================
  493. LightningDamage
  494. =================
  495. */
  496. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  497. {
  498.     local entity            e1, e2;
  499.     local vector            f;
  500.  
  501.     f = p2 - p1;
  502.     normalize (f);
  503.     f_x = 0 - f_y;
  504.     f_y = f_x;
  505.     f_z = 0;
  506.     f = f*16;
  507.  
  508.     e1 = e2 = world;
  509.  
  510.     traceline (p1, p2, FALSE, self);
  511.     if (trace_ent.takedamage)
  512.     {
  513.         particle (trace_endpos, '0 0 100', 225, damage*4);
  514.         T_Damage (trace_ent, from, from, damage);
  515.         if (self.classname == "player")
  516.         {
  517.             if (other.classname == "player")
  518.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  519.         }
  520.     }
  521.     e1 = trace_ent;
  522.  
  523.     traceline (p1 + f, p2 + f, FALSE, self);
  524.     if (trace_ent != e1 && trace_ent.takedamage)
  525.     {
  526.         particle (trace_endpos, '0 0 100', 225, damage*4);
  527.         T_Damage (trace_ent, from, from, damage);
  528.     }
  529.     e2 = trace_ent;
  530.  
  531.     traceline (p1 - f, p2 - f, FALSE, self);
  532.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  533.     {
  534.         particle (trace_endpos, '0 0 100', 225, damage*4);
  535.         T_Damage (trace_ent, from, from, damage);
  536.     }
  537. };
  538.  
  539. void() W_FireLightning =
  540.  {
  541.  
  542.     local   vector          org;
  543.     local     float cells;
  544.  
  545.     if (self.ammo_cells < 1)
  546.     {
  547.         self.weapon = W_BestWeapon ();
  548.         W_SetCurrentAmmo ();
  549.         return;
  550.     }
  551.  
  552. // explode if under water
  553.     if (self.waterlevel > 1)
  554.     {
  555.         cells=self.ammo_cells;
  556.         self.ammo_cells = 0;
  557.         T_RadiusDamage (self, self, 35*cells, world);
  558.         W_SetCurrentAmmo ();
  559.         return;
  560.     }
  561.  
  562.     if (self.t_width < time)
  563.     {
  564.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  565.         self.t_width = time + 0.6;
  566.     }
  567.     self.punchangle_x = -2;
  568.  
  569.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  570.  
  571.     org = self.origin + '0 0 16';
  572.     
  573.     traceline (org, org + v_forward*600, TRUE, self);
  574.  
  575.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  576.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  577.     WriteEntity (MSG_BROADCAST, self);
  578.     WriteCoord (MSG_BROADCAST, org_x);
  579.     WriteCoord (MSG_BROADCAST, org_y);
  580.     WriteCoord (MSG_BROADCAST, org_z);
  581.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  582.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  583.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  584.  
  585.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  586.     self.attack_finished=time+ 0.6;
  587. };
  588.  
  589.  
  590.  
  591. //=============================================================================
  592.  
  593.  
  594. void() GrenadeExplode =
  595. {
  596.     T_RadiusDamage (self, self.owner, 120, world);
  597.  
  598.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  599.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  600.     WriteCoord (MSG_BROADCAST, self.origin_x);
  601.     WriteCoord (MSG_BROADCAST, self.origin_y);
  602.     WriteCoord (MSG_BROADCAST, self.origin_z);
  603.  
  604.     BecomeExplosion ();
  605. };
  606.  
  607. void() GrenadeTouch =
  608. {
  609.     if (other == self.owner)
  610.         return;         // don't explode on owner
  611.     if (other.takedamage == DAMAGE_AIM)
  612.     {
  613.         GrenadeExplode();
  614.         return;
  615.     }
  616.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);  // bounce sound
  617.     if (self.velocity == '0 0 0')
  618.         self.avelocity = '0 0 0';
  619. };
  620.  
  621. /*
  622. ================
  623. W_FireGrenade
  624. ================
  625. */
  626. void() W_FireGrenade =
  627. {
  628.     local   entity missile, mpuff;
  629.     
  630.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  631.     
  632.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  633.  
  634.     self.punchangle_x = -2;
  635.  
  636.     missile = spawn ();
  637.     missile.owner = self;
  638.     missile.movetype = MOVETYPE_BOUNCE;
  639.     missile.solid = SOLID_BBOX;
  640.     missile.classname = "grenade";
  641.         
  642. // set missile speed    
  643.  
  644.     makevectors (self.v_angle);
  645.  
  646.     if (self.v_angle_x)
  647.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  648.     else
  649.     {
  650.         missile.velocity = aim(self, 10000);
  651.         missile.velocity = missile.velocity * 600;
  652.         missile.velocity_z = 200;
  653.     }
  654.  
  655.     missile.avelocity = '300 300 300';
  656.  
  657.     missile.angles = vectoangles(missile.velocity);
  658.     
  659.     missile.touch = GrenadeTouch;
  660.     
  661. // set missile duration
  662.     missile.nextthink = time + self.grenadetimer;
  663.     missile.think = GrenadeExplode;
  664.  
  665.     setmodel (missile, "progs/grenade.mdl");
  666.     setsize (missile, '0 0 0', '0 0 0');            
  667.     setorigin (missile, self.origin);
  668. };
  669.  
  670. //=============================================================================
  671.  
  672. void() spike_touch;
  673. void() superspike_touch;
  674.  
  675.  
  676. /*
  677. ===============
  678. launch_spike
  679.  
  680. Used for both the player and the ogre
  681. ===============
  682. */
  683. void(vector org, vector dir) launch_spike =
  684. {
  685.     newmis = spawn ();
  686.     newmis.owner = self;
  687.     newmis.movetype = MOVETYPE_FLYMISSILE;
  688.     newmis.solid = SOLID_BBOX;
  689.  
  690.     newmis.angles = vectoangles(dir);
  691.     
  692.     newmis.touch = spike_touch;
  693.     newmis.classname = "spike";
  694.     newmis.think = SUB_Remove;
  695.     newmis.nextthink = time + 6;
  696.     setmodel (newmis, "progs/spike.mdl");
  697.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);               
  698.     setorigin (newmis, org);
  699.  
  700.     dir = normalize (dir);
  701.  
  702. //Godel qc: increase nail speed
  703.     newmis.velocity = dir * 2000;
  704. };
  705.  
  706. void() W_FireSuperSpikes = {
  707.     local vector    dir;
  708.     local entity    old;
  709.  
  710.     local float     tog,ang;
  711.     
  712.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  713.  
  714.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  715.  
  716.     tog = 0;
  717.     if ((self.currentammo / 6) - floor(self.currentammo / 6) >= 0.5)
  718.         tog = 1;
  719.  
  720.     self.cnt = self.cnt + 0.01;
  721.     if (self.cnt > 0.1)
  722.         self.cnt = -0.1;
  723.     ang = fabs(self.cnt);
  724.  
  725.     dir = aim (self, 1000);
  726.     self.attack_finished = time + 0.2;
  727.  
  728.     dir = normalize (dir);
  729.  
  730.     makevectors (dir);
  731.  
  732.     makevectors(self.v_angle);
  733.     
  734.     launch_spike (self.origin + '0 0 16', dir);
  735.     newmis.touch = superspike_touch;
  736.     setmodel (newmis, "progs/s_spike.mdl");
  737.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);               
  738.     
  739.     self.punchangle_x = -2;
  740. };
  741.  
  742. void(float ox) W_FireSpikes =
  743. {
  744.     local vector    dir;
  745.     local entity    old;
  746.     
  747.     makevectors (self.v_angle);
  748.  
  749.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  750.     {
  751.         W_FireSuperSpikes ();
  752.         return;
  753.     }
  754.  
  755.     if (self.ammo_nails < 1)
  756.     {
  757.         self.weapon = W_BestWeapon ();
  758.         W_SetCurrentAmmo ();
  759.         return;
  760.     }
  761.  
  762.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  763.     self.attack_finished = time + 0.2;
  764.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  765.     dir = aim (self, 1000);
  766.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  767.  
  768.     self.punchangle_x = -2;
  769. };
  770.  
  771.  
  772.  
  773. .float hit_z;
  774. void() spike_touch =
  775. {
  776. local float rand;
  777.     if (other == self.owner)
  778.         return;
  779.  
  780.     if (other.solid == SOLID_TRIGGER)
  781.         return; // trigger field, do nothing
  782.  
  783.     if (pointcontents(self.origin) == CONTENT_SKY)
  784.     {
  785.         remove(self);
  786.         return;
  787.     }
  788.     
  789. // hit something that bleeds
  790.     if (other.takedamage)
  791.     {
  792.         spawn_touchblood (9);
  793.         T_Damage (other, self, self.owner, 9);
  794.     }
  795.     else
  796.     {
  797.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  798.         
  799.         if (self.classname == "wizspike")
  800.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  801.         else if (self.classname == "knightspike")
  802.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  803.         else
  804.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  805.         WriteCoord (MSG_BROADCAST, self.origin_x);
  806.         WriteCoord (MSG_BROADCAST, self.origin_y);
  807.         WriteCoord (MSG_BROADCAST, self.origin_z);
  808.     }
  809.  
  810.     remove(self);
  811.  
  812. };
  813.  
  814. void() superspike_touch =
  815. {
  816. local float rand;
  817.     if (other == self.owner)
  818.         return;
  819.  
  820.     if (other.solid == SOLID_TRIGGER)
  821.         return; // trigger field, do nothing
  822.  
  823.     if (pointcontents(self.origin) == CONTENT_SKY)
  824.     {
  825.         remove(self);
  826.         return;
  827.     }
  828.     
  829. // hit something that bleeds
  830.     if (other.takedamage)
  831.     {
  832.         spawn_touchblood (18);
  833.         T_Damage (other, self, self.owner, 18);
  834.     }
  835.     else
  836.     {
  837.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  838.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  839.         WriteCoord (MSG_BROADCAST, self.origin_x);
  840.         WriteCoord (MSG_BROADCAST, self.origin_y);
  841.         WriteCoord (MSG_BROADCAST, self.origin_z);
  842.     }
  843.  
  844.     remove(self);
  845.  
  846. };
  847.  
  848.  
  849. /*
  850. ===============================================================================
  851.  
  852. PLAYER WEAPON USE
  853.  
  854. ===============================================================================
  855. */
  856.  
  857. void() W_SetCurrentAmmo =
  858. {
  859.     local string wm;
  860.  
  861.     player_run ();          // get out of any weapon firing states
  862.  
  863.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  864.     
  865.     if (self.weapon == IT_AXE)
  866.     {
  867.         self.currentammo = 0;
  868.         wm = "progs/v_axe.mdl";
  869.         self.weaponframe = 0;
  870.     }
  871.     else if (self.weapon == IT_SHOTGUN)
  872.     {
  873.         self.currentammo = self.ammo_shells;
  874.         wm= "progs/v_shot.mdl";
  875.         self.weaponframe = 0;
  876.         self.items = self.items | IT_SHELLS;
  877.     }
  878.     else if (self.weapon == IT_SUPER_SHOTGUN)
  879.     {
  880.         self.currentammo = self.ammo_shells;
  881.         wm = "progs/v_shot2.mdl";
  882.         self.weaponframe = 0;
  883.         self.items = self.items | IT_SHELLS;
  884.     }
  885.     else if (self.weapon == IT_NAILGUN)
  886.     {
  887.         self.currentammo = self.ammo_nails;
  888.         wm = "progs/v_nail.mdl";
  889.         self.weaponframe = 0;
  890.         self.items = self.items | IT_NAILS;
  891.     }
  892.     else if (self.weapon == IT_SUPER_NAILGUN)
  893.     {
  894.         self.currentammo = self.ammo_nails;
  895.         wm = "progs/v_nail2.mdl";
  896.         self.weaponframe = 0;
  897.         self.items = self.items | IT_NAILS;
  898.     }
  899.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  900.     {
  901.         self.currentammo = self.ammo_rockets;
  902.         wm = "progs/v_rock.mdl";
  903.         self.weaponframe = 0;
  904.         self.items = self.items | IT_ROCKETS;
  905.     }
  906.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  907.     {
  908.         self.currentammo = self.ammo_rockets;
  909.         wm = "progs/v_rock2.mdl";
  910.         self.weaponframe = 0;
  911.         self.items = self.items | IT_ROCKETS;
  912.     }
  913.     else if (self.weapon == IT_LIGHTNING)
  914.     {
  915.         self.currentammo = self.ammo_cells;
  916.         wm = "progs/v_light.mdl";
  917.         self.weaponframe = 0;
  918.         self.items = self.items | IT_CELLS;
  919.     }
  920.     else
  921.     {
  922.         self.currentammo = 0;
  923.         wm = "";
  924.         self.weaponframe = 0;
  925.     }
  926.     if (wm!=self.weaponmodel) self.weaponnum=0;
  927.     self.weaponmodel=wm;
  928. };
  929.  
  930. float() W_BestWeapon =
  931. {
  932.     local   float   it,rv;
  933.     
  934.     it = self.items;
  935.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  936.         rv= IT_LIGHTNING;
  937.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  938.         rv= IT_SUPER_NAILGUN;
  939.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  940.         rv= IT_SUPER_SHOTGUN;
  941.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  942.         rv= IT_NAILGUN;
  943.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  944.         rv= IT_SHOTGUN;
  945.         
  946. /*
  947.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  948.         rv= IT_ROCKET_LAUNCHER;
  949.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  950.         rv= IT_GRENADE_LAUNCHER;
  951. */
  952.     else rv= IT_AXE;
  953.     return(rv);
  954. };
  955.  
  956. float() W_CheckNoAmmo =
  957. {
  958.     if (self.currentammo > 0)
  959.         return TRUE;
  960.  
  961.     if (self.weapon == IT_AXE)
  962.         return TRUE;
  963.     
  964.     self.weapon = W_BestWeapon ();
  965.  
  966.     W_SetCurrentAmmo ();
  967.     
  968. // drop the weapon down
  969.     return FALSE;
  970. };
  971.  
  972. /*
  973. ============
  974. W_Attack
  975.  
  976. An attack impulse can be triggered now
  977. ============
  978. */
  979.  
  980. void()  player_axe1;
  981. void()  player_axeb1;
  982. void()  player_axec1;
  983. void()  player_axed1;
  984. void()  player_shot1;
  985. void()  player_nail1;
  986. void()  player_light1;
  987. void()  player_rocket1;
  988.  
  989. void() W_Attack =
  990. {
  991.     local   float   r;
  992.  
  993.     if (!W_CheckNoAmmo ())
  994.         return;
  995.  
  996. //    Godel qc: Observers cannot attack;
  997.     if (self.flags & FL_OBSERVER) return;
  998.  
  999.     makevectors     (self.v_angle);                 // calculate forward angle for velocity
  1000.     self.show_hostile = time + 1;   // wake monsters up
  1001.  
  1002.     if (self.weapon == IT_AXE)
  1003.     {
  1004.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1005.         r = random();
  1006.         if (r < 0.25)
  1007.             player_axe1 ();
  1008.         else if (r<0.5)
  1009.             player_axeb1 ();
  1010.         else if (r<0.75)
  1011.             player_axec1 ();
  1012.         else
  1013.             player_axed1 ();
  1014.         self.attack_finished = time + 0.5;
  1015.     }
  1016.     else if (self.weapon == IT_SHOTGUN)
  1017.     {
  1018.         player_shot1 ();
  1019.         W_FireShotgun ();
  1020.         self.attack_finished = time + 0.5;
  1021.     }
  1022.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1023.     {
  1024.         player_shot1 ();
  1025.         W_FireSuperShotgun ();
  1026.         self.attack_finished = time + 0.7;
  1027.     }
  1028.     else if (self.weapon == IT_NAILGUN)
  1029.     {
  1030.         player_nail1 ();
  1031.     }
  1032.     else if (self.weapon == IT_SUPER_NAILGUN)
  1033.     {
  1034.         player_nail1 ();
  1035.     }
  1036.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1037.     {
  1038.         player_rocket1();
  1039.         if (self.weaponnum == 0) W_FireGrenade();
  1040.         else W_FirePipeBomb();
  1041.         self.attack_finished = time + 0.6;
  1042.     }
  1043.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1044.     {
  1045.         player_rocket1();
  1046.         if (self.weaponnum == 0) W_FireRocket();
  1047.         else W_FireTripBomb();
  1048.         self.attack_finished = time + 0.8;
  1049.     }
  1050.     else if (self.weapon == IT_LIGHTNING)
  1051.     {
  1052.         if (self.weaponnum == 0) {
  1053.             player_light1();
  1054.             sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1055.         } else if (self.weaponnum==1){
  1056.             player_light1();
  1057.             sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1058.  
  1059.         } else if (self.weaponnum==2){
  1060.             W_FireMinion();
  1061.         }
  1062.         self.attack_finished = time + 0.1;
  1063.     }
  1064. };
  1065.  
  1066.  
  1067. /*
  1068. ============
  1069. W_ChangeWeapon
  1070.  
  1071. ============
  1072. */
  1073. void() W_ChangeWeapon =
  1074. {
  1075.     local    float    it, am, fl, ow;
  1076.     
  1077.     it = self.items;
  1078.     am = 0;
  1079.     ow = self.weaponnum;
  1080.     
  1081.     if (self.impulse == 1)
  1082.     {
  1083.         fl = IT_AXE;
  1084.         if (self.weapon==IT_AXE) {
  1085.             if (self.weaponnum==0) {
  1086.                 sprint(self,"Shoving Hands Selected\n");
  1087.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1088.                 self.weaponnum=1; 
  1089.             } else {
  1090.                 sprint(self,"Vampiric Rune Axe Selected\n");
  1091.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1092.                 self.weaponnum=0;
  1093.             }
  1094.         }
  1095.     }
  1096.     else if (self.impulse == 2)
  1097.     {
  1098.         fl = IT_SHOTGUN;
  1099.         if (self.weapon==IT_SHOTGUN) {
  1100.             if (self.weaponnum==0) {
  1101.                 sprint(self,"Long Range Shotgun Selected\n");
  1102.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1103.                 self.weaponnum=1; 
  1104.             } else {
  1105.                 sprint(self,"Normal Shotgun Selected\n");
  1106.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1107.                 self.weaponnum=0;
  1108.             }
  1109.         }
  1110.         if (self.ammo_shells < 1)
  1111.             am = 1;
  1112.     }
  1113.     else if (self.impulse == 3)
  1114.     {
  1115.         fl = IT_SUPER_SHOTGUN;
  1116.         if (self.weapon==IT_SUPER_SHOTGUN) {
  1117.             if (self.weaponnum==0) {
  1118.                 sprint(self,"Long Range Super Shotgun Selected\n");
  1119.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1120.                 self.weaponnum=1; 
  1121.             } else {
  1122.                 sprint(self,"Normal Super Shotgun Selected\n");
  1123.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1124.                 self.weaponnum=0;
  1125.             }
  1126.         }
  1127.         if (self.ammo_shells < 2)
  1128.             am = 1;
  1129.     }        
  1130.     else if (self.impulse == 4)
  1131.     {
  1132.         fl = IT_NAILGUN;
  1133.         if (self.ammo_nails < 1)
  1134.             am = 1;
  1135.     }
  1136.     else if (self.impulse == 5)
  1137.     {
  1138.         fl = IT_SUPER_NAILGUN;
  1139.         if (self.ammo_nails < 2)
  1140.             am = 1;
  1141.     }
  1142.     else if (self.impulse == 6)
  1143.     {
  1144.         fl = IT_GRENADE_LAUNCHER;
  1145.         if (self.weapon==IT_GRENADE_LAUNCHER) {
  1146.             if (self.weaponnum==0) {
  1147.                 sprint(self,"Pipe Bombs Selected\n");
  1148.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1149.                 self.weaponnum=1; 
  1150.             } else {
  1151.                 sprint(self,"Grenade Launcher Selected\n");
  1152.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1153.                 self.weaponnum=0;
  1154.             }
  1155.         }
  1156.         if (self.ammo_rockets < 1)
  1157.             am = 1;
  1158.     } else if (self.impulse == 7) {
  1159.         fl = IT_ROCKET_LAUNCHER;
  1160.         if (self.weapon==IT_ROCKET_LAUNCHER) {
  1161.             if (self.weaponnum==0) {
  1162.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1163.                 if (self.ammo_rockets < 5){
  1164.                     sprint(self,"Rocket Launcher Selected\n");
  1165.                     self.weaponnum=0; 
  1166.                 }else{
  1167.                     sprint(self,"Trip Bombs Selected\n");
  1168.                     self.weaponnum=1; 
  1169.                 }
  1170.             } else {
  1171.                 sprint(self,"Rocket Launcher Selected\n");
  1172.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1173.                 self.weaponnum=0;
  1174.             }
  1175.             if (self.ammo_rockets < 1) am = 1;
  1176.         }
  1177.     }
  1178.     else if (self.impulse == 8)
  1179.     {
  1180.         fl = IT_LIGHTNING;
  1181.         if (self.weapon==IT_LIGHTNING) {
  1182.             if (self.weaponnum==1) {
  1183.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1184.                 if (self.ammo_cells < 80){
  1185.                     self.weaponnum=0;
  1186.                     sprint(self,"Lightning Gun Selected\n");
  1187.                 } else {
  1188.                     sprint(self,"Electric Minion Selected\n");
  1189.                     self.weaponnum=2; 
  1190.                 }
  1191.             } else if(self.weaponnum==0){
  1192.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1193.                 sprint(self,"Bouncing Lightning Gun Selected\n");
  1194.                 self.weaponnum=1;
  1195.             } else {
  1196.                 sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM);
  1197.                 sprint(self,"Lightning Gun Selected\n");
  1198.                 self.weaponnum=0;
  1199.             }
  1200.             if (self.ammo_cells < 1) am = 1;
  1201.         }
  1202.     }
  1203.  
  1204.     self.impulse = 0;
  1205.     
  1206.     if (!(self.items & fl))
  1207.     {    // don't have the weapon or the ammo
  1208.         sprint (self, "no weapon.\n");
  1209.         return;
  1210.     }
  1211.     
  1212.     if (am)
  1213.     {    // don't have the ammo
  1214.         sprint (self, "not enough ammo.\n");
  1215.         self.weaponnum=ow;
  1216.         return;
  1217.     }
  1218.  
  1219. //
  1220. // set weapon, set ammo
  1221. //
  1222.     if (self.weapon!=fl) self.weaponnum=0;
  1223.     self.weapon = fl;        
  1224.     W_SetCurrentAmmo ();
  1225. };
  1226.  
  1227. /*
  1228. ============
  1229. CheatCommand
  1230. ============
  1231. */
  1232. void() CheatCommand =
  1233. {
  1234.     if (deathmatch || coop)
  1235.         return;
  1236.  
  1237.     self.ammo_rockets = 100;
  1238.     self.ammo_nails = 200;
  1239.     self.ammo_shells = 100;
  1240.     self.ammo_cells = 200;
  1241.     
  1242.     self.items = self.items | 
  1243.         IT_AXE |
  1244.         IT_SHOTGUN |
  1245.         IT_SUPER_SHOTGUN |
  1246.         IT_NAILGUN |
  1247.         IT_SUPER_NAILGUN |
  1248.         IT_GRENADE_LAUNCHER |
  1249.         IT_ROCKET_LAUNCHER |
  1250.     IT_KEY1 | IT_KEY2 |
  1251.         IT_LIGHTNING;
  1252.  
  1253.     self.weapon = IT_ROCKET_LAUNCHER;
  1254.     
  1255.     self.impulse = 0;
  1256.     W_SetCurrentAmmo ();
  1257. };
  1258.  
  1259. /*
  1260. ============
  1261. CycleWeaponCommand
  1262.  
  1263. Go to the next weapon with ammo
  1264. ============
  1265. */
  1266. void() CycleWeaponCommand = {
  1267.     local   float   it, am;
  1268.     
  1269.     it = self.items;
  1270.     self.impulse = 0;
  1271.     self.weaponnum=0;
  1272.     
  1273.     while (1)
  1274.     {
  1275.         am = 0;
  1276.  
  1277.         if (self.weapon == IT_AXE) {
  1278.             self.weapon = IT_SHOTGUN;
  1279.             if (self.ammo_shells < 1)
  1280.                 am = 1;
  1281.         } else if (self.weapon == IT_SHOTGUN) {
  1282.             self.weapon = IT_SUPER_SHOTGUN;
  1283.             if (self.ammo_shells < 2)
  1284.                 am = 1;
  1285.         } else if (self.weapon == IT_SUPER_SHOTGUN) {
  1286.             self.weapon = IT_NAILGUN;
  1287.             if (self.ammo_nails < 1)
  1288.                 am = 1;
  1289.         } else if (self.weapon == IT_NAILGUN) {
  1290.             self.weapon = IT_SUPER_NAILGUN;
  1291.             if (self.ammo_nails < 2)
  1292.                 am = 1;
  1293.         } else if (self.weapon == IT_SUPER_NAILGUN) {
  1294.             self.weapon = IT_GRENADE_LAUNCHER;
  1295.             if (self.ammo_rockets < 1)
  1296.                 am = 1;
  1297.         } else if (self.weapon == IT_GRENADE_LAUNCHER) {
  1298.             self.weapon = IT_ROCKET_LAUNCHER;
  1299.             if (self.ammo_rockets < 1)
  1300.                 am = 1;
  1301.         } else if (self.weapon == IT_ROCKET_LAUNCHER) {
  1302.             self.weapon = IT_LIGHTNING;
  1303.             if (self.ammo_cells < 1)
  1304.                 am = 1;
  1305.         } else if (self.weapon == IT_LIGHTNING) {
  1306.             self.weapon = IT_AXE;
  1307.         }
  1308.         if ( (it & self.weapon) && am == 0) {
  1309.             W_SetCurrentAmmo ();
  1310.             return;
  1311.         }
  1312.     }
  1313. };
  1314.  
  1315. /*
  1316. ============
  1317. CycleWeaponReverseCommand
  1318.  
  1319. Go to the prev weapon with ammo
  1320. ============
  1321. */
  1322. void() CycleWeaponReverseCommand =
  1323. {
  1324.     local    float    it, am;
  1325.     
  1326.     it = self.items;
  1327.     self.impulse = 0;
  1328.  
  1329.     while (1)
  1330.     {
  1331.         am = 0;
  1332.  
  1333.         if (self.weapon == IT_LIGHTNING)
  1334.         {
  1335.             self.weapon = IT_ROCKET_LAUNCHER;
  1336.             if (self.ammo_rockets < 1)
  1337.                 am = 1;
  1338.         }
  1339.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1340.         {
  1341.             self.weapon = IT_GRENADE_LAUNCHER;
  1342.             if (self.ammo_rockets < 1)
  1343.                 am = 1;
  1344.         }
  1345.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1346.         {
  1347.             self.weapon = IT_SUPER_NAILGUN;
  1348.             if (self.ammo_nails < 2)
  1349.                 am = 1;
  1350.         }
  1351.         else if (self.weapon == IT_SUPER_NAILGUN)
  1352.         {
  1353.             self.weapon = IT_NAILGUN;
  1354.             if (self.ammo_nails < 1)
  1355.                 am = 1;
  1356.         }
  1357.         else if (self.weapon == IT_NAILGUN)
  1358.         {
  1359.             self.weapon = IT_SUPER_SHOTGUN;
  1360.             if (self.ammo_shells < 2)
  1361.                 am = 1;
  1362.         }        
  1363.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1364.         {
  1365.             self.weapon = IT_SHOTGUN;
  1366.             if (self.ammo_shells < 1)
  1367.                 am = 1;
  1368.         }
  1369.         else if (self.weapon == IT_SHOTGUN)
  1370.         {
  1371.             self.weapon = IT_AXE;
  1372.         }
  1373.         else if (self.weapon == IT_AXE)
  1374.         {
  1375.             self.weapon = IT_LIGHTNING;
  1376.             if (self.ammo_cells < 1)
  1377.                 am = 1;
  1378.         }
  1379.     
  1380.         if ( (it & self.weapon) && am == 0)
  1381.         {
  1382.             W_SetCurrentAmmo ();
  1383.             return;
  1384.         }
  1385.     }
  1386.  
  1387. };
  1388.  
  1389. /*
  1390. ============
  1391. ServerflagsCommand
  1392.  
  1393. Just for development
  1394. ============
  1395. */
  1396. void() ServerflagsCommand =
  1397. {
  1398.     serverflags = serverflags * 2 + 1;
  1399. };
  1400.  
  1401. void() QuadCheat =
  1402. {
  1403.     if (deathmatch || coop)
  1404.         return;
  1405.     self.super_time = 1;
  1406.     self.super_damage_finished = time + 30;
  1407.     self.items = self.items | IT_QUAD;
  1408.     dprint ("quad cheat\n");
  1409. };
  1410.  
  1411.  
  1412. void() teleport_effect_do =
  1413. {
  1414.     self.nextthink = time + 0.2;
  1415.     self.think = SUB_Remove;
  1416.     sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_NORM);
  1417.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1418.     WriteByte (MSG_BROADCAST, TE_TELEPORT);
  1419.     WriteCoord (MSG_BROADCAST, self.origin_x);
  1420.     WriteCoord (MSG_BROADCAST, self.origin_y);
  1421.     WriteCoord (MSG_BROADCAST, self.origin_z);
  1422. };
  1423.  
  1424. void(vector org, float thinktime) teleport_effect =
  1425. {
  1426.     local entity s;
  1427.  
  1428.     s = spawn ();
  1429.     s.origin = org;
  1430.     s.nextthink = time + thinktime;
  1431.     s.think = teleport_effect_do;
  1432. };
  1433.  
  1434. /*
  1435. ============
  1436. ImpulseCommands
  1437.  
  1438. ============
  1439. */
  1440. void() ImpulseCommands =
  1441. {
  1442.     local float item_type;
  1443.     local float loopy;
  1444.     local entity found;        
  1445.     local string a;
  1446.  
  1447.     if (self.impulse==0) return;
  1448.     else if (self.impulse >= 1 && self.impulse <= 8)
  1449.         W_ChangeWeapon ();
  1450.     else if (self.impulse == 9)
  1451.         CheatCommand ();
  1452.     else if (self.impulse == 10)
  1453.         CycleWeaponCommand();
  1454.     else if (self.impulse == 11)
  1455.         ServerflagsCommand ();
  1456.     else if (self.impulse == 12)
  1457.         CycleWeaponReverseCommand();
  1458. /*    Done by design not forgetfullness. :)
  1459.     else if (self.impulse == 15)
  1460.         W_Remember ();
  1461.     else if (self.impulse == 16)
  1462.         W_Teleport ();
  1463. */
  1464.     else if (self.impulse == 17){
  1465.         if(teamplay==7 && world_flag<3){
  1466.             bprint(self.netname);
  1467.             bprint(" removes the Flags and Bases\n");
  1468.         } else if (teamplay==8 && world_hill){
  1469.             bprint(self.netname);
  1470.             bprint(" removes the Hill\n");
  1471.         }
  1472.         RemoveFlagsAndBases();
  1473.         RemoveHill();
  1474.     }
  1475.     else if (self.impulse == 18) 
  1476.     {
  1477.         if (teamplay == 7){
  1478.             if (world_flag) W_PlaceFlag ();
  1479.             else DropFlagCheck(FALSE);
  1480.         } else if (teamplay == 8){
  1481.             PlaceHill();
  1482.         }
  1483.     }
  1484.     else if (self.impulse == 19) {
  1485.         if(teamplay==2) teamplay=4;    
  1486.         else if(teamplay==5) teamplay=7;
  1487.         else if(teamplay==8) teamplay=0;
  1488.         else teamplay=teamplay+1;
  1489.         a=ftos(teamplay);
  1490.         cvar_set("teamplay",a);
  1491.     }
  1492.     else if (self.impulse == 20) {
  1493.         self.team=1;
  1494.     }
  1495.     else if (self.impulse == 52)
  1496.         DetPipeBombs();
  1497.     else if ((self.impulse == 53) | (self.impulse == 54))
  1498.         SetGrenadeTimer();
  1499.     else if ((self.impulse==55) | (self.impulse==56) | (self.impulse==57))
  1500.         TossBackpack();
  1501.     else if (self.impulse == 58)
  1502.         W_FireHolo();
  1503.     else if ((self.impulse == 200) || (self.impulse == 201))
  1504.     {
  1505.         if (self.impulse == 200)
  1506.         {
  1507.         self.skin = self.skin + 1;
  1508.         if (self.skin == 19) self.skin = 0;
  1509.         } else
  1510.         if (self.impulse == 201)
  1511.         {
  1512.         self.skin = self.skin - 1;
  1513.         if (self.skin == -1) self.skin = 18;
  1514.         }
  1515.         if (self.skin == 0) centerprint(self, "SKIN: Quake himself (1)"); else
  1516.         if (self.skin == 1) centerprint(self, "SKIN: Duke Nukem 3d (2)"); else
  1517.         if (self.skin == 2) centerprint(self, "SKIN: Mr. Toad (3)"); else
  1518.         if (self.skin == 3) centerprint(self, "SKIN: the Stormtrooper (4)"); else
  1519.         if (self.skin == 4) centerprint(self, "SKIN: Max (5)"); else
  1520.         if (self.skin == 5) centerprint(self, "SKIN: the Terminator (6)"); else
  1521.         if (self.skin == 6) centerprint(self, "SKIN: Judge Dredd (7)"); else
  1522.         if (self.skin == 7) centerprint(self, "SKIN: Camouflaged soldier (8)"); else
  1523.         if (self.skin == 8) centerprint(self, "SKIN: Captain Picard (9)"); else
  1524.         if (self.skin == 9) centerprint(self, "SKIN: the Wizzard (10)"); else
  1525.         if (self.skin == 10) centerprint(self,"SKIN: the Predator (11)"); else
  1526.         if (self.skin == 11) centerprint(self,"SKIN: Skeleton (12)"); else
  1527.         if (self.skin == 12) centerprint(self,"SKIN: Wan-Fu (13)"); else
  1528.         if (self.skin == 13) centerprint(self,"SKIN: Henry Rollins (14)"); else
  1529.         if (self.skin == 14) centerprint(self,"SKIN: He-Man (15)"); else
  1530.         if (self.skin == 15) centerprint(self,"SKIN: Boba (16)"); else
  1531.         if (self.skin == 16) centerprint(self,"SKIN: Superman (17)"); else
  1532.         if (self.skin == 17) centerprint(self,"SKIN: NYPD Cop (18)"); else
  1533.         if (self.skin == 18) centerprint(self,"SKIN: Red/Yellow women dude (19)");
  1534.     }
  1535.  
  1536.     else if (self.impulse == 210)
  1537.         Observer();
  1538.     else if (self.impulse == 255)
  1539.         QuadCheat();
  1540.     self.impulse = 0;
  1541. };
  1542.  
  1543. /*
  1544. ============
  1545. W_WeaponFrame
  1546.  
  1547. Called every frame so impulse events can be handled as well as possible
  1548. ============
  1549. */
  1550. void() W_WeaponFrame =
  1551. {
  1552.     if (time < self.attack_finished)
  1553.         return;
  1554.     ImpulseCommands ();
  1555.  
  1556.     
  1557. // check for attack
  1558.     if (self.button0)
  1559.     {
  1560.         W_Attack ();
  1561.     }
  1562. };
  1563.  
  1564.